// user
var user_Boolean = false;
var password_Boolean = false;
var varconfirm_Boolean = false;

var t1;//提示1 用户输入框
var t2;//提示2 密码框1
var t3;//提示3 密码框2


//账户
$('.reg_user').blur(function(){
  var name1=$("#name").val();
console.log("昵称"+name1);
    $.ajax({
      type:"post",
      url:"http://localhost:9090/verifyuser",
      data:{"name":name1},
      datatype:"application/json",
      success:function (sj){
        console.log("返回数据"+sj);
        if ((/^[a-z0-9_-]{4,8}$/).test($(".reg_user").val())&sj==0){
            console.log("可以添加");
            $('.user_hint').html("✔").css("color","green");
            t1=1;
            user_Boolean = true;
        }else {
          console.log("不可以添加");
          $('.user_hint').html("×").css("color","red");
          t1=0;
          user_Boolean = false;
        }
      }
    })



});
// 密码
$('.reg_password').blur(function(){
  if ((/^[a-z0-9_-]{6,16}$/).test($(".reg_password").val())){
    $('.password_hint').html("✔").css("color","green");
    t2=1;
    password_Boolean = true;
  }else {
    $('.password_hint').html("×").css("color","red");
    t2=0;
    password_Boolean = false;
  }
});


//密码相等为true
// password_confirm
$('.reg_confirm').blur(function(){
  if (($(".reg_password").val())==($(".reg_confirm").val())){
    $('.confirm_hint').html("✔").css("color","green");
    t3=1;
    varconfirm_Boolean = true;
  }else {
    $('.confirm_hint').html("×").css("color","red");
    t3=0;
    varconfirm_Boolean = false;
  }
});

function zc(){
  // var ts1=$("#ts1").val();
  var name=$("#name").val();
  var pass=$("#pass").val();
  console.log(t1);
  console.log(t2);
  console.log(t3);
  // console.log(t1==t2==t3);
  if (t1==t2==t3){
    window.location="http://localhost:9090/enroll?name="+name+"&pass="+pass;
  }

}
